package com.listeningframework.boot.codegen.generators.coders;

import com.listeningframework.boot.codegen.constants.Templates;
import com.listeningframework.boot.codegen.context.MetaContext;
import com.listeningframework.boot.codegen.exception.BusinessException;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * 
 * @description Repository Coder 
 *
 * @author lixining
 * @version $Id: RepositoryCoder.java, v 0.1 2016年12月5日 下午1:53:59 lixining Exp $
 */
public class RepositoryCoder extends AbstractCoder {

    public RepositoryCoder(MetaContext context) {
        super(context);
    }

    @Override
    protected String getContent() throws BusinessException {
        return render(Templates.REPOSITORY);
    }

    @Override
    protected Map<String, Object> getParams() {
        Map<String, Object> paramMap = newHashMap();
        paramMap.put(CLASS_PACKAGE, context.getRepositoryPackage());
        // Imports
        Set<String> imports = new HashSet<>();
        imports.add(context.getClz().getName());
        paramMap.put(CLASS_IMPORTS, imports);
        return paramMap;
    }

    @Override
    protected String getSavePath() throws BusinessException {
        return context.getRepositoryPath();
    }

}
